package com.cskaoyan.controller.admin;

import com.cskaoyan.bean.MarketComment;
import com.cskaoyan.bean.common.BasePageInfo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.service.admin.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description
 * @Author klw
 * @Data 2022/11/20 下午6:52
 */


@RestController
@RequestMapping("admin/comment")  //  评论模块
public class CommentController {

    @Autowired
    CommentService commentService;

    @GetMapping("list")  //list 接口 列表
    public BaseRespVo<CommonData>list(Integer userId, Integer valueId, BasePageInfo basePageInfo){
        CommonData<MarketComment> query = commentService.query(userId, valueId, basePageInfo);

        return BaseRespVo.ok(query);
    }

    @PostMapping("delete")
    public BaseRespVo delete(@RequestBody MarketComment marketComment){
        commentService.delete(marketComment);

        return BaseRespVo.ok();
    }

    @PostMapping("reply")
    public BaseRespVo reply(Integer commentId, String content){
        if(null == content){
            return BaseRespVo.error(401,"参数不对");
        }
        int res = commentService.reply(commentId,content);
        if(res == 622){
            return BaseRespVo.error(622,"订单商品已回复");
        }

        return BaseRespVo.ok();
    }
}
